package com.abbcc.module.admin;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;

import com.abbcc.action.BaseAction;
import com.abbcc.common.CommonConst;
import com.abbcc.models.TdEmailAccount;
import com.abbcc.service.EmailAccountService;

public class EmailAction extends BaseAction<TdEmailAccount>{
	@Autowired
	EmailAccountService emailAccountService;
	
	public String list(){
		DetachedCriteria dc = DetachedCriteria.forClass(entityClass);
		pageList = emailAccountService.findPageByCriteria(dc,pageSize,startIndex);
		saveLog("email服务器", "查询", CommonConst.LOGFIND, CommonConst.LOGTYPEBYADMIN);
		return LIST;
	}
	public String del(){
		emailAccountService.load(entity, entity.getCountId());
		emailAccountService.delete(entity);
		result = "删除成功!";
		saveLog("email服务器", result, CommonConst.LOGDEL, CommonConst.LOGTYPEBYADMIN);
		return list();
	}
	public String edit(){
		emailAccountService.load(entity, entity.getCountId());
		return EDIT;
	}
	public String update(){
		emailAccountService.update(entity);
		result = "修改成功!";
		saveLog("email服务器", result, CommonConst.LOGUPDATE, CommonConst.LOGTYPEBYADMIN);
		return list();
	}
	public String save(){
		emailAccountService.save(entity);
		result = "添加成功!";
		saveLog("email服务器", result, CommonConst.LOGSAVE, CommonConst.LOGTYPEBYADMIN);
		return list();
	}

}
